package cn.edu.cqvie.jdk8.stream2;

import java.util.function.Consumer;
import java.util.function.IntConsumer;

public class ConsumerTest {


    public static void main(String[] args) {

        ConsumerTest consumerTest = new ConsumerTest();
        Consumer<Integer> integerConsumer = i -> System.out.println(i);
        IntConsumer intConsumer = i -> System.out.println(i);

        System.out.println(integerConsumer instanceof Consumer);
        System.out.println(intConsumer instanceof IntConsumer);

        //面向对象方式
        consumerTest.test(integerConsumer);
        //函数式方式
        consumerTest.test(integerConsumer::accept);
        //函数式方式
        consumerTest.test(intConsumer::accept);

    }

    public void test(Consumer<Integer> consumer) {
        consumer.accept(100);
    }
}
